package yue.shen.android.demo.adapter;

import android.content.Context;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import java.util.List;

import yue.shen.android.demo.R;

public abstract class BaseRViewActivity<T> extends AppCompatActivity implements RViewCreate<T>, SwipeRefreshHelper.SwipeRefreshListener {

    protected RViewHelper<T> helper;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycle_view);
        helper = new RViewHelper.Builder<T>(this, this).build();
    }

    @Override
    public Context context() {
        return this;
    }

    @Override
    public SwipeRefreshLayout createSwipeRefresh() {
        return findViewById(R.id.swipe_refresh_layout);
    }

    @Override
    public RecyclerView createRecycleView() {
        return findViewById(R.id.recycle_view);
    }

    @Override
    public boolean isSupportPaging() {
        return false;
    }

    protected void notifyAdapterDataSetChanged(List<T> list){
        helper.notifyAdapterDataSetChanged(list);
    }
}
